<template>
    <div>
        <h1>科室修改</h1>
        <table class="table">
            <tr>
                <td>科室名称</td>
                <td>
                    <input type="text" v-model="data.kname">
                </td>
            </tr>

            <tr>
                <td>科室人数</td>
                <td>
                    <input type="text" v-model="data.ksnum">
                </td>
            </tr>

            <tr>
                <td>科室描述</td>
                <td>
                    <textarea v-model="data.kRemark"></textarea>
                </td>
            </tr>

            <tr>
                <td>创建日期</td>
                <td>
                    <input type="date" v-model="data.kCreateTime">
                </td>
            </tr>

            <tr>
                <td></td>
                <td>
                    <input type="button" class="btn btn-success" value="提交" @click="add">
                </td>
            </tr>
        </table>
    </div>
</template>

<script setup lang="ts">
import {ref,onMounted} from 'vue'
import axios from 'axios'
import moment from 'moment';
import { useRouter,useRoute } from 'vue-router';
const router=useRouter()
const route=useRoute()
//反填
const ft=()=>{
    
    axios.get("/api/Ks/GetId",{params:{id:route.query.id}}).then(res=>{
        data.value=res.data
        data.value.kCreateTime=moment(data.value.kCreateTime).format("yyyy-MM-DD")
    })
}
onMounted(()=>{
    ft()
})
const data=ref({
  "kname": "",
  "ksnum": null,
  "kRemark": "",
  "kCreateTime": "",
})
//修改
const add=()=>{
    debugger
    axios.post("/api/Ks/UpdKs",data.value).then(res=>{
        if(res.data>0){
            alert('修改成功');
            router.push("/ksshow")
        }
        else{
            alert('修改失败');
            return
        }
    })
}
</script>

<style scoped>

</style>